#ifndef _MyGenCreator_H_
#define _MyGenCreator_H_

#include <map>
#include <string>

typedef void* (*CreateMyGen)();

class MyGenCreator
{
public:
    static MyGenCreator& GetInstance()
    {
        static MyGenCreator Instance;
        return Instance;
    }
    inline void RegistMyGen(std::string name, CreateMyGen gPSGen) {m_AvaiableMyGen[name] = gPSGen;}
    void* CreateNewMyGen(std::string);

    ~MyGenCreator();

private:
    MyGenCreator();

    std::string m_MyGenName;
    std::map<std::string, CreateMyGen> m_AvaiableMyGen;

};

#define REGISTGPSGEN(name)\
void* CREATE##name(){\
    name* fil = new name();\
    return (fil == nullptr) ? nullptr : fil;\
}\
class REGIST##name\
{\
public:\
    REGIST##name()\
    {\
        MyGenCreator::GetInstance().RegistMyGen(#name, CREATE##name);\
    }\
};\
REGIST##name regist##name;

#endif